<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<title>系统-用户列表</title>
		<meta name="description" content="overview &amp; stats" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
		<!-- bootstrap & fontawesome -->
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/bootstrap.min.css" />
		<link rel="stylesheet" href="${request.contextPath}/static/assets/font-awesome/4.7.0/css/font-awesome.min.css" />
		<!-- page specific plugin styles -->
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/daterangepicker.min.css" />
		<!-- text fonts -->
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/fonts.googleapis.com.css" />
		<!-- ace styles -->
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/ace.min.css" class="ace-main-stylesheet" id="main-ace-style" />
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/ace-skins.min.css" />
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/ace-rtl.min.css" />
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/jquery.gritter.min.css" />
		<link rel="stylesheet" href="${request.contextPath}/static/stylesheets/console.css" />
		<!-- ace settings handler -->
		<script src="${request.contextPath}/static/assets/js/ace-extra.min.js"></script>
	</head>

	<body class="skin-2" style="background-color: #FFF;">
		  <div class="tabbable">
			<div class="tab-content">
				<div id="manage" class="tab-pane active in">
					<div class="row">
						<div class="col-xs-12">
							<div class="clearfix">
								<div class="pull-left tableTools-container">
									<button class="btn btn-xs btn-primary" onclick="skip('${request.contextPath}/user/newUser')"><i class="ace-icon fa fa-pencil-square-o align-top bigger-125"></i>新增</button>
								</div>
							</div>
							<!-- PAGE CONTENT BEGINS -->
							<div id="dynamic-table_wrapper" class="dataTables_wrapper form-inline no-footer">
								<table id="dynamic-table" class="table table-striped table-bordered table-hover dataTable no-footer" role="grid" aria-describedby="dynamic-table_info">
									<thead>
										<tr>
											<th>No.</th>
											<th>登录名</th>
											<th>姓名</th>
											<th>邮箱</th>
											<th>电话</th>
											<th>是否允许登录</th>
											<th>最后登陆日期</th>
											<th>操作</th>
										</tr>
									</thead>
									<tbody>
										<#list page.rows as user>
											<tr class="">
												<td>${user_index + 1}</td>
												<td>${user.loginName!}</td>
												<td>${user.name!}</td>
												<td>${user.email!}</td>
												<td>${user.phone!}</td>
												
												<td>
												<#if user.useable==1>
																是
															<#else>
																否
															</#if>
												</td>
												
												<#if user.loginDate??>
												<td>${user.loginDate?string('yyyy-MM-dd HH:mm:ss')}</td>
												<#else>
												<td>从未登录</td>
												</#if>
												<td>
													<input type="hidden" id="user" name="user" value="${user.id}">
													<a class="btn btn-minier btn-primary" href="${request.contextPath}/user/editUser?id=${user.id!}" role="button">编辑</a>
													<button class="btn btn-minier btn-danger deleteUser" userId="${user.id}" role="button">删除</button>
													<button class="btn btn-minier btn-primary enableUser" userId="${user.id}" role="button"><#if user.useable==1>停用<#else>启用</#if></button>
												</td>
											</tr>
										</#list>
									</tbody>
								</table>
								<#include "/common/gridpager.html">
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script src="${request.contextPath}/static/assets/js/jquery-2.1.4.min.js"></script>
		<script type="text/javascript">
			if('ontouchstart' in document.documentElement) document.write("<script src='${request.contextPath}/static/assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
			
		</script>
		<script src="${request.contextPath}/static/assets/js/bootstrap.min.js"></script>

		<!-- page specific plugin scripts -->
		<script src="${request.contextPath}/static/assets/js/jquery-ui.min.js"></script>
		<script src="${request.contextPath}/static/assets/js/jquery.ui.touch-punch.min.js"></script>
		<script src="${request.contextPath}/static/assets/js/jquery.gritter.min.js"></script>

		<!-- ace scripts -->
		<script src="${request.contextPath}/static/assets/js/ace-elements.min.js"></script>
		<script src="${request.contextPath}/static/assets/js/ace.min.js"></script>
		<script src="${request.contextPath}/static/assets/js/bootbox.js"></script>
		<!-- user scripts -->
		<script src="${request.contextPath}/static/assets/js/user/base.js"></script>
		<script type="text/javascript">
			jQuery(function($) {
				//刪除用户
		    	$('.deleteUser').click(function(){
		    		var id = $(this).attr('userId');
		    		if(id == '1'){
			    		reminder("超级管理员不允许被删除！");
			    		return;
		    		}
		    		bootbox.dialog({
						message: "确定删除吗？", 
						buttons: {
							"success" : {
								"label" : "确定",
								"className" : "btn-sm btn-primary",
								"callback" :function(){
									$.ajax({
										type : 'post',
										url : '${request.contextPath}/user/deleteUser',
										dataType : 'json',
										data : {
											id : id,
										},
										success : function(result){
                                            console.log(result);
											if(result.code==0){
												window.location.reload();
											}else{
												reminder(result.message);
											}
										}
									});
								}
							}
						}
					});
		    	});
				//停用,启用 用户
		    	$('.enableUser').click(function(){
		    		var id = $(this).attr('userId');
		    		$.ajax({
						type : 'POST',
						url : '${request.contextPath}/user/enableUser',
						dataType : 'json',
						data : {
							id : id,
						},
						success : function(result){
							if(result.code==0){
								window.location.reload();
							}else{
								reminder(result.message);
							}
						}
					});
		    	});
			})
		</script>
	</body>
</html>